package com.zhupanlin.order.feign.fallback;

import com.zhupanlin.order.feign.ProductFeignClient;
import com.zhupanlin.product.bean.Product;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 描述信息：
 *
 * @author zhupanlin
 * @version 1.0
 * @date 2025/1/24 13:52
 */
@Component
public class ProductFeignClientFallback implements ProductFeignClient {
    /**
     * 远程服务调用失败时才调用该兜底方法
     * @param productId
     */
    @Override
    public Product getProductById(Long productId) {

        System.out.println("兜底回调");
        Product product = new Product();
        product.setId(productId);
        product.setPrice(new BigDecimal("0"));
        product.setProductName("未知商品");
        product.setNum(0);

        return product;
    }
}